package com.geezdata.cps.ttk.query.query.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.geezdata.cps.base.utils.BeanUtil;
import com.geezdata.cps.ttk.common.vo.UserResVO;
import com.geezdata.cps.ttk.domain.domain.User;
import com.geezdata.cps.ttk.mapper.mapper.UserMapper;
import com.geezdata.cps.ttk.query.query.RoleService;
import com.geezdata.cps.ttk.query.query.UserRoleService;
import com.geezdata.cps.ttk.query.query.UserService;


@Service
public class UserServiceImpl implements UserService {
	@Autowired
    protected UserMapper userMapper;
	
	@Autowired
    protected RoleService roleService;
	
	@Autowired
    protected UserRoleService userRoleService;
	
	@Override
	public UserResVO getUserDetailByUserName(String userName, Integer status) {
		User condition = new User();
		condition.setUserName(userName);
		condition.setStatus(status);
		User user = userMapper.selectOne(condition);
		if(user == null) {
			return null;
		}
		UserResVO userVO = BeanUtil.convert(user, UserResVO.class);
		userVO.setRoleList(userRoleService.getUserRoleList(userVO.getUserId(), null, 1));
		return userVO;
	}
}